package concurrency.chapter6;

public class ThreadCloseGraceful2 {
    private static class Worker extends Thread{

        @Override
        public void run() {
            while (true){
                if (Thread.interrupted())
                    break;//return
            }
            //TODO-------
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Worker worker=new Worker();
        worker.start();
        Thread.sleep(4000);
        //通过打断来控制线程结束
        worker.interrupt();
    }

}
